<template>
	<div class="icons">
		<swiper :options="swiperOptionSecond" ref="mySwiper">
	    	<swiper-slide v-for="(page,index) in pages" :key="index">
	    		<div class="icon" v-for="item in page">
	    			<div class="icon-img">
						<img class="icon-img-content" :src='item.imgUrl'/>
					</div>
					<p class="icon-desc">{{item.desc}}</p>
	    		</div>
	    	</swiper-slide>
		</swiper>
	</div>
</template>

<script>
	export default {
		name:'HomeIcons',
		props:{
			list:Array
		},
		data(){
			return{
				swiperOptionSecond: {
		          autoplay:false
		        },
				testDate:[{
					imgUrl:require('../../../assets/imgs/5.jpeg'),
					desc:'时装'
				},{
					imgUrl:require('../../../assets/imgs/6.jpeg'),
					desc:'坐骑'
				},{
					id:'7',
					imgUrl:require('../../../assets/imgs/7.jpeg'),
					desc:'飞剑'
				},{
					imgUrl:require('../../../assets/imgs/8.jpeg'),
					desc:'武器'
				},{
					imgUrl:require('../../../assets/imgs/5.jpeg'),
					desc:'时装2'
				}]
			}
		},
		methods:{

		},
		computed:{
			pages(){
				const pages = []
				this.list.forEach((item,index)=> {
					const page = Math.floor(index/4)
					if(!pages[page]){
						pages[page] = []
					}
					pages[page].push(item)
				})
				return pages
			}
		}
	}
</script>

<style lang="stylus" scoped>
  @import '~styles/varibles.styl'
  /*@import '~styles/mixins.styl'
  .icons >>> .swiper-container
    
  .icons >>> .swiper-slider
  	width:100%*/

  .icons
    margin-top: .1rem
    .icon
      position: relative
      overflow: hidden
      float: left
      width: 25%
      height: 25%
      .icon-img
        
        .icon-img-content
          display: block
          margin: 0 auto
          width: 100%
      .icon-desc
  	     margin-top: 1px
  	     height: 0.44rem
  	     line-height: 0.44rem
  	     text-align: center
      
</style>